package cn.com.cym.gamezao.entity.demo;

import cn.com.cym.gamezao.base.BaseEntity;
import cn.com.cym.gamezao.entity.demo.Child;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
@Entity
@Table(name ="x_parent")
@ApiModel(description = "父类")
public class Parent  extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 5709972708544963173L;

    @Column(length = 60)
    private String name;

    @Column(length = 60)
    private String code;


    /**
     * mappedBy 添加后不再新建关联表
     * fetch 获取子表的方式
     * JsonIgnore 控制子表获取到主表死循环，数据过大的问题,增加在父表，无法直接获取到子表的数据，所以挂载在子表中
     */
   /* @JsonIgnore*/
    @OneToMany(mappedBy="parent",fetch = FetchType.EAGER)
    private List<Child> child;

}
